package com.kk.factory.simplefactory;

import java.util.Scanner;

/**
 * @author 王志强
 * @date 2021-12-10
 */
public class OrderPizza {

    public OrderPizza() {
        AbstractPizza pizza;
        String type;

        while (true) {
            type = getType();
            if ("greek".equals(type)) {
                pizza = new GreekPizza();
            } else if ("cheese".equals(type)) {
                pizza = new CheesePizza();
            } else {
                break;
            }

            pizza.prepare();

        }
    }

    private String getType() {
        Scanner scanner = new Scanner(System.in);
        return scanner.nextLine();
    }
}
